-
Notifications
You must be signed in to change notification settings - Fork 179
add function to retreive index's section memory size and use this to get symbol table size #272
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting started here! Now that we have the function to retrieve the data, we need to expose it as a prometheus metric.
Take this as an example: https://github.com/prometheus/tsdb/blob/master/db.go#L131-L138
We similarly need a metric which adds up all the symbol tables from all the blocks.
index/index.go
Outdated
// getSectionSize returns the first 4 bytes in a section starting at offset off | ||
// to get the content length bytes | ||
func (r *Reader) getSectionSize(off int) int { | ||
if off == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this check.
index/index.go
Outdated
} | ||
b := r.b.Range(off, off+4) | ||
var l int | ||
if l <= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm, l
has just been declared hence will always be 0.
index/index.go
Outdated
return l | ||
} | ||
|
||
// getSymbolTableSize returns the bytes taken by the symbol table of Reader object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end comments with .
I have facing some difficulty in exposing symbol-table len to IndexReader interface. |
@fabxc @brian-brazil |
@@ -84,6 +84,9 @@ type IndexReader interface { | |||
// LabelIndices returns a list of string tuples for which a label value index exists. | |||
LabelIndices() ([][]string, error) | |||
|
|||
// GetSymbolTableSize returns the size occupied by the symbol table of Reader object. | |||
GetSymbolTableSize() uint32 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has nothing to do with functionality of an IndexReader
and makes strong assumptions about how it is implemented. However we want to expose it, this interface isn't it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same question in this #297 PR.
There I have added a new interface IndexExtra
for exposing LabelName() function.
Does this way work or is there any other way to expose functions from index.go ?
@sipian, do you plan to work on this? |
@codesome |
Superseded by #375 |
#244
I have added a function in index/index.go to get a section's size.
Acc to documentation of index.md & this comment, a sections 1st 4 bytes holds the big endian encoded content length .
For symbol table size I retrieve these 4 bytes from (r.toc.symbols offsets)